<?php
use common\library\comFun;
use yii\helpers\Url;
use yii\helpers\ArrayHelper;

?>
<fieldset class="layui-elem-field layui-field-title" style="">

    <legend>筛选</legend>
    <form class="layui-form layui-form-pane">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">昵称</label>
                <div class="layui-input-inline">
                    <input type="text" name="nickname" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">电话号码</label>
                <div class="layui-input-inline">
                    <input type="text" name="mobile" class="layui-input">
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">角色</label>
                <div class="layui-input-block">
                    <select name="role">
                        <option value="">全部</option>
                        <? foreach ($roleList as $key => $value): ?>
                            <?php
                            $level = '';
                            switch ($value['level']) {
                                case 0:
                                    $level = '├─  ';
                                    break;
                                case 1:
                                    $level = '│    ├─  ';
                                    break;
                                case 2:
                                    $level = '│    │    ├─  ';
                                    break;
                                case 3:
                                    break;
                            }
                            ?>
                            <option
                                value="<?= $value['personnel_class_id'] ?>" <?php if (!empty($info) && $info['parent_id'] == $value['personnel_class_id']) {
                                echo 'selected';
                            } ?> ><?= $level . $value['class_name'] ?></option>
                        <? endforeach ?>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <button class="layui-btn" lay-submit="" lay-filter="demo1">查询</button>
            </div>
        </div>
    </form>
</fieldset>

<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
    <ul class="layui-tab-title">
        <li <?php if ($status == 1): ?>class="layui-this"<?php endif; ?> ><a
                href="<?= Url::toRoute(['member/list', 'status' => 1]) ?>">在职</a></li>
        <li <?php if ($status == 0): ?>class="layui-this"<?php endif; ?> ><a
                href="<?= Url::toRoute(['member/list', 'status' => 0]) ?>">离职</a></li>
    </ul>
    <table class="layui-table">
        <colgroup>
            <col>
            <col>
            <col width="150">
            <col width="200">
            <col width="100">
            <col width="180">
        </colgroup>
        <thead>
        <tr>
            <th>昵称</th>
            <th>电话号码</th>
            <th>角色</th>
            <th>注册时间</th>
            <th>状态</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <?php
        foreach ($list as $data) {
            ?>
            <tr>
                <td><?= ArrayHelper::getValue($data, 'nickname') ?></td>
                <td><?= ArrayHelper::getValue($data, 'mobile') ?></td>
                <td>
                    <?= $showRole[$data['role']] ?>
                </td>
                <td><?= comFun::formatDate($data['register_time']) ?></td>
                <td><?php if ($data['status'] == 1) {
                        echo '在职';
                    } else {
                        echo '离职';
                    } ?></td>
                <td>
                    <div class="layui-btn-group">
                        <a href="<?= Url::toRoute(['member/info', 'member_id' => $data['member_id']]) ?>"
                           class="layui-btn layui-btn-small">查看</a>
                        <a href="<?= Url::toRoute(['member/out-info', 'member_id' => $data['member_id']]) ?>"
                           class="layui-btn layui-btn-small">导出</a>
                        <button data-url="<?= Url::toRoute(['member/del', 'member_id' => $data['member_id']]) ?>"
                                class="o-del-btn layui-btn layui-btn-small layui-btn-danger">删除
                        </button>
                    </div>
                </td>
            </tr>
            <?php
        }
        ?>

        </tbody>
    </table>
    <div id="o-page" data-pages="<?= $pageArr['pageTotal'] ?>"></div>
</div>
<script>
    layui.use(['form'], function () {
        layui.form();
    });
</script>